package it.univaq.mwt.common.action;

import it.univaq.mwt.log.LivelloLog;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;

public class ManageLanguageAction extends MappingDispatchAction {

	public ActionForward switchLanguage(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		String language=null;
		if(request.getParameter("lan")!=null){
			language=request.getParameter("lan").toString();
			
			if(language.equals("it")){
				setLocale(request, Locale.ITALIAN);
			}
			if(language.equals("en")){
				setLocale(request, Locale.ENGLISH);
			}
			
		}
		
		return null;
		
	}
	
}
